<?php
/**
 * 各功能模块的其它方法:AJAX
 */
class AjaxController extends Yaf_Controller_Abstract
{	
	const NET_OK = 10;
	const NET_NOAUTH = 20;
	/**
	 * 初始化,禁用自动渲染
     * @method init
	 */
	public function init()
	{
		Yaf_Dispatcher::getInstance()->disableView(); // 关闭模板
	}
	private function json($data)
	{
		header('Content-type: application/json');
		echo json_encode($data);
	}
	public function unicode_decode($name)
	{
		//转换编码，将Unicode编码转换成可以浏览的utf-8编码
		$name = str_replace("\\","%",$name);//把\u变成%u
		return $this->unescape($name);
	}

	/** 
 	* js escape php 实现(与unescape对应) 
 	* @param $string           the sting want to be escaped 
 	* @param $in_encoding       
 	* @param $out_encoding      
 	*/ 
	private function escape($string, $in_encoding = 'UTF-8',$out_encoding = 'UCS-2') 
	{
		$return = ''; 
    	if (function_exists('mb_get_info')) 
    	{
    		for($x = 0; $x < mb_strlen ( $string, $in_encoding ); $x ++) 
    		{ 
            	$str = mb_substr ( $string, $x, 1, $in_encoding ); 
            	if (strlen ( $str ) > 1) 
            	{ // 多字节字符 
                	$return .= '%u' . strtoupper ( bin2hex ( mb_convert_encoding ( $str, $out_encoding, $in_encoding ) ) ); 
            	} else 
            	{ 
                	$return .= '%' . strtoupper ( bin2hex ( $str ) ); 
            	} 
        	} 
    	} 
    	return $return; 
    }

	/** 
 	* js unescape php 实现(与escape对应) 
 	* @param $string           the sting want to be unescape   
 	*/
	private function unescape($str) 
	{ 
    	$ret = ''; 
    	$len = strlen($str); 
    	for ($i = 0; $i < $len; $i ++) 
    	{ 
        	if ($str[$i] == '%' && $str[$i + 1] == 'u') //只取%u后面的部分
        	{ 
        		/*取出其中的十六进制值并将16进制转换成10进制*/
            	$val = hexdec(substr($str, $i + 2, 4)); 
            	if ($val < 0x7f) //对应ASCii码的范围(0~127)
                	$ret .= chr($val); //返回Unicode编码
            	else  
	                if ($val < 0x800) //<2048
    	                $ret .= chr(0xc0 | ($val >> 6)) . chr(0x80 | ($val & 0x3f)); 
                	else 
                    	$ret .= chr(0xe0 | ($val >> 12)) . chr(0x80 | (($val >> 6) & 0x3f)) . chr(0x80 | ($val & 0x3f)); 
						$i += 5; 
        	} else  
            	if ($str[$i] == '%') 
            	{ 
                	$ret .= urldecode(substr($str, $i, 3)); //将url编码还原
                	$i += 2; 
            	} else 
                	$ret .= $str[$i]; 
    	} 
    	return $ret; 
    }
	/**
	 * 登录操作
	 * @method loginAction
	 * @param  string      $value [description]
	 * @return [type]             [description]
	 * @author NewFuture
	 */
	public function loginSystemAction()
	{

		$user = cookie::get('user');
		if ($user)
		{	
			$response['status'] = 2;
			$response['info']   = '您目前处于登录状态!';
			$response['url']    = '/index/';
		}else{
			$param['userName']         = trim($this->getRequest()->getPost('userName'));
			$param['password']         = rsa::decode($this->unicode_decode(trim($this->getRequest()->getPost('password'))));

		    if(!($param['userName'] && $param['password']))
			{
			 	$response['status'] = 0;
			 	$response['info']   = '参数不对';
			 }else{
				// $user             = net::inst('auth')->checkUserPwd($param);
				// if ($user->ret == self::NET_OK)
				// {
				// 	$response['status'] = 1;
				// 	$response['url']    = '/index/';
				// 	$response['info']   = '登录成功';
				// 	$cookie['id']       = $user->userId;//用户id来自后台
				// 	$cookie['name']     = $param['userName'];
				// 	cookie::set('user',$cookie);
				// }else{
				// 	$response['status'] = 0;
				//  	$response['info'] = $user->msg;
				 	
				// }
				$response['status'] = 1;
				$response['url']    = '/index/';
				$response['info']   = '登录成功';
				$cookie['name'] = $param['userName'];
				cookie::set('user',$cookie);
			}
		}
		$this->json($response);
	}
	/**
	 * 判断权限
     * @method checkAuthorityAction
	 */
	function checkAuthorityAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$permit["userId"]       = $user["id"];
		$permit["functionId"]   = $param->getRequest('functionId');
		$permit["deptId"]       = $param->getRequest('deptId');
		$permitAuth             = net::inst('auth')->checkPermit($permit);
		if($permitAuth->ret==self::NET_NOAUTH){
			$response["status"] = "succeed";
			$response["flag"] = 0;
		}else if($permitAuth->ret==self::NET_OK){
			$response["status"] = "succeed";
			$response["flag"] = 1;
		}else if($permitAuth->ret==self::NET_SERVICEERROR){
			$response["status"] = "fail";
			$response["msg"] = $permitAuth->msg;
		}
		$this->json($response);
	}
	/**
	 * 修改密码
     * @method updatePasswordAction
	 */
	function updatePasswordAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                        = $this->getRequest();//获取查询参数
		$initParam["adminId"]         = $user["id"];
		$initParam["orginPassword"]   = $param->getRequest('old_pwd');
		$initParam["currentPassword"] = $param->getRequest('new_pwd');
		$result             = net::inst('northBG')->userPassword($initParam);
		if($result->ret==self::NET_OK){
			cookie::del('user');
			$response["status"] = "succeed";
			$response["info"] = $result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] = $result->msg;
		}
		$this->json($response);
	}
	/**
	*判断层内是否设置了路点
	*@method checkPointAction
	*/
	public function checkPointAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/login/');
			return false;
		}
		$params = $_POST;
		//echo json_encode($params);
		$result = net::inst('autoBG')->checkPoint($params);
		if(isset($result->ret)&&$result->ret == self::NET_OK){
			$response['status'] = 'succeed';
			//$response['info'] = $result->msg;
			$response['flag'] = $result->flag;
		}else if(isset($result->ret)&&$result->ret == self::NET_NOAUTH){
			$response['status'] = 'fail';
			$response['info'] = $result->msg;
		}else{
			$response['error'] = '服务器连接错误！';
		}
		$this->json($response);
	}
	/**
	 * excel导入
     * @method excelImportAction
	 */
	function importExcelAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$fileType = $this->getRequest()->getRequest('fileType');
		$params   = array("type","vin","ein","color","hubNum","fuelType","dpm","seatNum");
		//$path     = excel::resourceDir().'/excel/';
		$carList  = excel::importExcel($_FILES[$fileType],"0777",$params);
		$status   = "succeed";
		$info     = "";
		if(is_array($carList)){
			$initParam["userId"]          = $user["id"];
			$initParam["list"]            = $carList;
			$result             = net::inst('northBG')->insertBatchVehicle($initParam);
			if($result->ret==self::NET_OK){
				$info = $result->msg;
			}else if($result->ret==31){
				$status = "fail";
				$info = '导入的车辆信息中由于'.substr($result->msg,0, strlen($result->msg)-1).'车架号已存在,请重新导入!';
			}else{
				$status = "fail";
				$info = $result->msg;
			}
		}else{
			$status = "fail";
			$info = $carList;
		}
		echo "{";
		echo				"status: '" . $status . "',\n";
		echo				"info: '" . $info . "'\n";
		echo "}";
	}
	/**
	*客户类型找客户
	*@method buyerByTypeAction
	*/
	public function buyerByTypeAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/login/');
			return false;
		}
		$buyType = $_POST;
		$result = net::inst('northBG')->buyerByType($buyType);
		if($result->ret == self::NET_OK){
			$input='<option value="">请选择</option>';
			if(!empty($result->list)&&count($result->list)>0){
				
				foreach ($result->list as $key => $list) {
					$input.='<option value="'.$list->id.'">'.$list->buyerName.'</option>';
				}
			}
	
			$response["status"] = "succeed";
			$response["info"] =$input;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	
	/**
	*获得买方详情
	*@method checkBuyerName
	*/
	public function buyerInfoAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/login/');
			return false;
		}
		$buyerInfo = $_POST;
		$result = net::inst('northBG')->buyerInfo($buyerInfo);
		if($result->ret == self::NET_OK){
			$response['status'] = 'succeed';
			//$response['info'] = json_encode($result);
			$response['info'] = $result->list[0]->phone;
			$response['info1'] = $result->list[0]->buyerId;
			$response['info2'] = $result->list[0]->taxpayerNo;
			$response['info3'] = $result->list[0]->accountNo;
			$response['info4'] = $result->list[0]->bankName;
			$response['info5'] = $result->list[0]->accountAddr;
		}else{
			$response['status'] = 'fail';
			$response['info'] = $result->msg;
		}
		$this->json($response);
	}
	/**
	*放行
	*@method releaseInfoAction
	*/
	public function releaseInfoAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/');
			return false;
		}
		$release = $_POST;
		
		$result = net::inst('northBG')->releaseDetail($release);
		if($result->ret == self::NET_OK){
			$detail =$result->list[0];
			$input='';
			if($detail->type=="1")
				$input.='<option value="1" selected="selected">还款后放车</option>';
            else
            	$input.='<option value="1" >还款后放车</option>';
            if($detail->type=="2")
				$input.='<option value="2" selected="selected">当日未还款款已入华星账户放车</option>';
            else
            	$input.='<option value="2">当日未还款款已入华星账户放车</option>';
            if($detail->type=="3")
				$input.='<option value="3" selected="selected">当日未入账放车</option>';
            else
            	$input.='<option value="3" >当日未入账放车</option>';
			$response["status"] = "succeed";
			$response["info"] =$input;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	*提示
	*@method warnAction
	*/
	public function warnAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/login/');
			return false;
		}
		$warn = $_POST;
		$result = net::inst('northBG')->warn($warn);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$response["info"] =$result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	*放行
	*@method releaseAction
	*/
	public function releaseAction(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/index/');
			return false;
		}
		$release = $_POST;
		$result = net::inst('northBG')->release($release);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$response["info"] =$result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	 * 管理员
     * @method adminStatusAction
	 */
	function userStatusAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                    = $this->getRequest();//获取查询参数
		$inParam["adminId"]       = $param->getRequest('adminId');
		$inParam["flag"]          = $param->getRequest('status');
		$inParam["userId"]        = $user["id"]; 
		$result = net::inst('northBG')->userStatus($inParam);
		if($result->ret == self::NET_OK){
			$response['status'] = "succeed";
			$response['info'] = $result->msg;
		}else{
			$response['status'] = "fail";
			$response['info'] = $result->msg;
		}
		$this->json($response);
	}
	/**
	 * 给用户添加角色
     * @method distributRoleRightAction
	 */
	function distributRoleRightAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["adminId"]     = $param->getRequest('adminId');
		$inParam["roleId"]      = explode(',',$param->getRequest('roleId'));
		$inParam["userId"]      = $user["id"];
		$result = net::inst('northBG')->distributRoleRight($inParam);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$response["info"] =$result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	 * 给用户添加角色
     * @method distributRoleLeftAction
	 */
	function distributRoleLeftAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["roleId"]      = explode(',',$param->getRequest('roleId'));
		$inParam["adminId"]     = $param->getRequest('adminId');
		$result = net::inst('northBG')->distributRoleLeft($inParam);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$response["info"] =$result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	 * 查询用户的角色
     * @method distributRoleInitAction
	 */
	function distributRoleInitAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["adminId"]     = $param->getRequest('adminId');
		$result = net::inst('northBG')->distributRoleInit($inParam);
		$outHtml='';
		$ownHtml='';
		if($result->ret == self::NET_OK){
			if(!empty($result->outRoleList) && count($result->outRoleList)>0){
                foreach ($result->outRoleList as $key => $outRole) {
                   $outHtml.='<option value="'.$outRole->roleId.'" class="option">'.$outRole->roleName.'</option>';
                }
            }
            if(!empty($result->ownRoleList) && count($result->ownRoleList)>0){
                foreach ($result->ownRoleList as $key => $ownRole) {
                    if($ownRole->status  == "0")
                       $ownHtml.='<option value="'.$ownRole->roleId.'" class="option" style="color:red;">'.$ownRole->roleName.'</option>';
                    else
                        $ownHtml.='<option value="'.$ownRole->roleId.'" class="option">'.$ownRole->roleName.'</option>';
                }
            }
            $response["status"] = "succeed";
            $response["outRole"] = $outHtml;
            $response["ownRole"] = $ownHtml;
            $response["userName"] = $result->userName;
		}else{
			$response["status"] = "fail";
            $response["info"] = $result->msg;
		}
		$this->json($response);
	}
	/**
	 * 角色状态
     * @method roleStatusAction
	 */
	function roleStatusAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                    = $this->getRequest();//获取查询参数
		$inParam["roleId"]        = $param->getRequest('roleId');
		$inParam["flag"]          = $param->getRequest('status');
		$inParam["userId"]        = $user["id"]; 
		$result = net::inst('northBG')->roleStatus($inParam);
		if($result->ret == self::NET_OK){
			$response['status'] = "succeed";
			$response['info'] = $result->msg;
		}else{
			$response['status'] = "fail";
			$response['info'] = $result->msg;
		}
		$this->json($response);
	}
	/**
	 * 通过部门查询权限
     * @method searchAuthByDeptAction
	 */
	function searchAuthByDeptAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["deptId"]      = $param->getRequest('deptId');
		$inParam["roleId"]      = $param->getRequest('roleId');
		$result = net::inst('northBG')->distributPermInit($inParam);
		$outHtml='';
		$ownHtml='';
		if($result->ret == self::NET_OK){
			if(!empty($result->outFunctionList) && count($result->outFunctionList)>0){
                foreach ($result->outFunctionList as $key => $outFunction) {
                    $outHtml.='<option value="'.$outFunction->functionId.'" byDept="'.$outFunction->byDept.'" subSystem="'.$outFunction->subSystem.'" class="option">'.$outFunction->functionName.'</option>';
                }
            }
            if(!empty($result->ownFunctionList) && count($result->ownFunctionList)>0){
                foreach ($result->ownFunctionList as $key => $ownFunction) {
                    $ownHtml.='<option value="'.$ownFunction->functionId.'" byDept="'.$ownFunction->byDept.'" subSystem="'.$ownFunction->subSystem.'" class="option">'.$ownFunction->functionName.'</option>';
                }
            }
            $response["status"] = "succeed";
            $response["outFunction"] = $outHtml;
            $response["ownFunction"] = $ownHtml;
		}else{
			$response["status"] = "fail";
            $response["info"] = $result->msg;
		}
		$this->json($response);
	}
	/**
	 * 给角色添加权限
     * @method distributRightAction
	 */
	function distributRightAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["deptId"]      = $param->getRequest('dept');
		$inParam["functionId"]  = explode(',',$param->getRequest('functionId'));
		$inParam["roleId"]      = $param->getRequest('roleId');
		$inParam["subSystems"]  = explode(',',$param->getRequest('subSystemList'));
		$inParam["userId"]      = $user["id"];
		$result = net::inst('northBG')->distributRight($inParam);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$response["info"] =$result->msg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	 * 给角色添加权限
     * @method distributRightAction
	 */
	function distributLeftAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                  = $this->getRequest();//获取查询参数
		$inParam["functionId"]  = explode(',',$param->getRequest('functionId'));
		$inParam["roleId"]      = $param->getRequest('roleId');
		$inParam["deptId"]      = $param->getRequest('dept');
		$result = net::inst('northBG')->distributLeft($inParam);
		if($result->ret == self::NET_OK){
			$response["status"] = "succeed";
			$showMsg=$result->msg;
			if(!empty($result->list)&&count($result->list)>0){
				$count = count($result->list);
				$showMsg.='其中';
				for($i=0;$i<$count;$i++){
					$showMsg.=$result->list[$i];
					if($i!=$count-1)
						$showMsg.='';
				}
				$showMsg.='这'.$count.'个权限是全部门权限,因此权限移除后,角色仍具备此'.$count.'个权限,若想移除,选择"全部门权限"进行移除';
			}
			$response["info"] =$showMsg;
		}else{
			$response["status"] = "fail";
			$response["info"] =$result->msg;
		}
		$this->json($response);
	}
	/**
	 * 用户分配权限
     * @method authAction
	 */
	function authAction(){
		$user = cookie::get('user');
		if (!$user)
		{
			$this->redirect("/index/");
			return;
		}
		$param                       = $this->getRequest();//获取查询参数
		$inParam["userId"]           = $param->getRequest('adminId');
		$inParam["deptId"]           = $param->getRequest('deptId');
		$userAuth = net::inst('northBG')->distributAuthInit($inParam);
		if($userAuth->ret == self::NET_OK){
			$response['status'] = "succeed";
			$ticket1 ='{"code":"parent","id":1,"name":"vehicle", open:true,"nodes":[';
			$ticketFlag = false;
			$number = count($userAuth->outFunction);
			$outHtml="[";
			if(!empty($userAuth->outFunction) && $number>0){
				$c=0;
				foreach ($userAuth->outFunction as $key => $out) {
					$c++;
					if($out->subSystem=="vehicle"){
						$ticketFlag = true;
						if($out->byDept==1)
							$ticket1.='{"code":"'.$out->functionId.'","id":"'.$out->functionId.'","name":"'.$out->functionName.'","byDept":"1","subSystem":"vehicle"}';
						else
							$ticket1.='{"code":"'.$out->functionId.'","id":"'.$out->functionId.'","name":"'.$out->functionName.'","byDept":"0","subSystem":"vehicle"}';
						if($c<$number)
							$ticket1.=',';
					}
					
				}
				$ticket1.=']}';
				
			}
			if($ticketFlag)
				$outHtml.=$ticket1;
			$outHtml.="]";
			//拥有权限
			$ticket2 ='{"code":"parent","id":"vehicle","name":"vehicle", open:true,"nodes":[';
			$ticketFlag = false;
			$n = count($userAuth->ownFunction);
			$ownHtml="[";
			if(!empty($userAuth->ownFunction) && $n>0){
				$c=0;
				foreach ($userAuth->ownFunction as $key => $own) {
					$c++;
					if($own->subSystem=="vehicle"){
						$ticketFlag = true;
						if($own->byDept==1)
							$ticket2.='{"code":"'.$own->functionId.'","id":"'.$own->functionId.'","name":"'.$own->functionName.'","byDept":"1","subSystem":"vehicle"}';
						else
							$ticket2.='{"code":"'.$own->functionId.'","id":"'.$own->functionId.'","name":"'.$own->functionName.'","byDept":"0","subSystem":"vehicle"}';
					
						if($c<$n)
							$ticket2.=',';

					}
				}
				$ticket2.=']}';
			}
			if($ticketFlag)
				$ownHtml.=$ticket2;
			$ownHtml.="]";
			//特殊赋权
			$ownSpecial="";
			if(!empty($userAuth->ownSpecialFunction) && count($userAuth->ownSpecialFunction)>0){
				$i=1;
				foreach ($userAuth->ownSpecialFunction as $key => $specialFunction) {
					$ownSpecial.='<tr>
									<td>'.$specialFunction->functionName.'</td>';
                    $ownSpecial.='<td><input type="checkbox" value="'.$specialFunction->functionId.'" class="special" id="special'.$i.'"/>
                                  </td></tr>';
					$i++;
				}
			}else{
				$ownSpecial.="<tr><td colspan='4'>该用户没有特殊赋予的权限</td></tr>";
			}
			//拒绝特殊赋权
			$ownRefush="";
			if(!empty($userAuth->ownSpecialRefushFunction) && count($userAuth->ownSpecialRefushFunction)>0){
				$i=1;
				foreach ($userAuth->ownSpecialRefushFunction as $key => $ownSpecialRefush) {
					$ownRefush.='<tr><td>'.$ownSpecialRefush->functionName.'</td>';
                    
                    $ownRefush.='<td><input type="checkbox" value="'.$ownSpecialRefush->functionId.'" class="refush" id="refush'.$i.'"/></td>
                    			  </tr>';
    			    $i++;
				}
			}else{
				$ownRefush.="<tr><td colspan='4'>该用户没有赋予拒绝的权限</td></tr>";
			}
			
			$response['out'] = $outHtml;
			$response['own'] = $ownHtml;
			$response['ownSpecial'] = $ownSpecial;
			$response['ownRefush'] = $ownRefush;
		}else{
			$response['status'] = "fail";
			$response['info'] = $userAuth->msg;
		}
		$this->json($response);
	}
	/**
	 * 图片上传功能
	 *@method uploadImageAction
	 */
	public function uploadImageAction(){
		$param        = $this->getRequest();//获取查询参数
		$fileName     = $param->getRequest('filePath');
		$imageType     = $param->getRequest('imageType');
		$rootPath = upload::resourceDir("resource")."/".$fileName."/";
		$basePath = "/".$fileName."/";
		$status = "succeed";
		$info="";
		$path='';
		$reResult = upload::createSaveDir($rootPath,0777);
		
		if($reResult->value){
			$reResult = upload::checkFilesError($_FILES[$imageType]);
			if($reResult->value)
				$reResult = upload::moveUploadedFile($_FILES[$imageType],$rootPath,0777);
		}
		if(!$reResult->value){
			$status = "fail";
			$info = $reResult->result;
		}else{
			$status = "succeed";
			$info = "文件上传成功";
			$path = $basePath.$reResult->result;
		}
		// echo "{";
		// echo				"status: '" . $status . "',\n";
		// echo				"info: '" . $info . "',\n";
		// echo				"path: '" . $path . "'\n";
		// echo "}";
		$response['status'] = $status;
		$response['info'] = $info;
		$response['path'] = $path;
		echo json_encode($response);
	}
	}
